package org.example.iocdemo.ioc.controller;

import org.example.iocdemo.ioc.config.UserInfo;
import org.example.iocdemo.ioc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 * Description:做渐进主义的改良派,不做完没注意的速成派
 * User: XALEXC
 * Date: 2024-10-27
 * Time: 19:38
 */
@Controller
public class UserController {


  /*  private UserService us;
    private UserInfo userInfo;*/
    // 构造方法注入

   /* @Autowired
    public UserController(UserService us){
        this.us = us;
    }

    public UserController(UserService us, UserInfo userInfo) {
        this.us = us;
        this.userInfo = userInfo;
    }*/

    //Setter方法注入
   /* private UserService us;

    @Autowired
    public void setUs(UserService us) {
        this.us = us;
    }*/
    //属性注入
    @Autowired
    private UserService userService;

   /* @Qualifier("userInfo2")
    @Autowired
    private UserInfo user;*/
    @Resource(name = "userInfo2")
    private UserInfo user;

    public void doController() {
        userService.doService();
        System.out.println(user);
        System.out.println("do Controller...");
    }
}
